def electron_confirm(n):
    max_electrons = {
        's': 2,
        'p': 6,
        'd': 10,
        'f': 14,
    }
    # 初始化电子排布字典
    result = {}
    current_shell = 1
    current_subshell = 's'
    last_subshell = 's'
    for i in range(1, n + 1):
        # 如果当前能级已满，则转到下一个能级
        # s, p, d, f 顺序循环，每个能层最多有4个能级（除了第一层只有s）
        if (i == 3 or i == 11 or i == 19 or i == 31 or i == 37 or i == 49 or i == 54):
            current_shell += 1
            mid = current_subshell
            last_subshell = mid
            current_subshell = 's'
        elif (i == 21 or i == 39):
            current_shell -= 1
            current_subshell = last_subshell
        if result.get(current_shell, {}).get(current_subshell, 0) < max_electrons[current_subshell]:
            # 如果当前能级未满，则填充电子
            if current_shell not in result:
                result[current_shell] = {}
            result[current_shell][current_subshell] = result[current_shell].get(current_subshell, 0) + 1
        else:
            next_order = ['s', 'p', 'd', 'f']  # 其他层可以按照s, p, d, f的顺序填充
            next_index = (next_order.index(current_subshell) + 1) % len(next_order)
            next_subshell = next_order[next_index]
            current_subshell = next_subshell
            # 如果当前能级未满，则填充电子
            if current_shell not in result:
                result[current_shell] = {}
            if result.get(current_shell, {}).get(current_subshell, 0) < max_electrons[current_subshell]:
                result[current_shell][current_subshell] = result[current_shell].get(current_subshell, 0) + 1
    # 格式化输出
    for shell,subshells in result.items():
        for subshell,count in subshells.items():
            print(f"{shell}{subshell}{count}", end=' ')
        print()
    print(result)
# 输入电子数
n = int(input().strip())
electron_confirm(n)
